// 回路电阻测试仪
import { unitMap } from '@/config';
import { formateDateTimeNew, formatUnit } from './format';
import type { ConfigItem } from '@/types/tester';

export const loopConfig: ConfigItem[] = [
  {
    label: '测试时间',
    key: 'datetime',
    start: 0,
    length: 7,
    dataType: 'unit8',
    format: formateDateTimeNew,
    description: '测试时间',
    serverKey: 'monitorTime',
  },
  {
    label: '相别',
    key: 'phase',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'phase',
    editable: true,
    editType: 'select',
    editOptions: ['A相', 'B相', 'C相'],
  },
  {
    label: '环境温度',
    key: 'ambientTemperature',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'ambientTemperature',
    editable: true,
    editType: 'input',
    unit: unitMap['0x11'],
  },
  {
    label: '空气湿度',
    key: 'airHumidity',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'airHumidity',
    editable: true,
    editType: 'input',
    unit: unitMap['0x08'],
  },
  {
    label: '备注',
    key: 'remark',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'remark',
    editable: true,
    editType: 'input',
  },
  {
    label: '电流',
    key: 'current',
    start: 7,
    length: 4,
    dataType: 'float',
    readUnit: 'currentUnit',
    precision: 1,
    serverKey: 'electricCurrent',
    serverUnit: unitMap['0x09'],
  },
  {
    label: '电流单位',
    key: 'currentUnit',
    start: 11,
    length: 1,
    dataType: 'unit8',
    format: formatUnit,
    hide: true,
  },
  {
    label: '电阻',
    key: 'resistance',
    start: 12,
    length: 4,
    dataType: 'float',
    precision: 2,
    readUnit: 'resistanceUnit',
    serverKey: 'circuitResistance',
    serverUnit: unitMap['0x0E'],
  },
  {
    label: '电阻单位',
    key: 'resistanceUnit',
    start: 16,
    length: 1,
    dataType: 'unit8',
    format: formatUnit,
    hide: true,
  },
];
